#ifndef ALGORITHMS_LINEARLIST_H
#define ALGORITHMS_LINEARLIST_H
#include <iostream>
#include <cstdio>
#include <sstream>
#include "../exception/illegalParameterValue.h"

using std::ostream;
template <class T>
class LinearList{
public:
    virtual ~LinearList()= default;;
    virtual bool empty() const = 0;
    virtual int size() const = 0;
    virtual T& get(int theIndex) const = 0;
    virtual int indexOf(const T& theElement) const = 0;
    virtual void erase(int theIndex) = 0;
    virtual void insert(int theIndex,const T& theElement) = 0;
    virtual void output(ostream& out) const = 0;
};

template <class T>
T max(T a,T b){
    return a>=b?a:b;
}
template <class T>
void changeLength1D(T*& a,int oldLength,int newLength){
    if(newLength<0){
        throw illegalParameterValue("new length must be >= 0");
    }
    T* temp = new T[newLength];
    int number = min<int>(oldLength,newLength);
    copy(a,a+number,temp);
    delete[] a;
    a = temp;
}
#endif //ALGORITHMS_LINEARLIST_H
